package com.jlu.test.index;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

public class ESTest_Search {

  public static void main(String[] args) throws IOException {

//    创建es客户端
    RestHighLevelClient client = new RestHighLevelClient(
            RestClient.builder(new HttpHost("localhost",9200, "http"))
    );

//    查询索引
    GetIndexRequest request = new GetIndexRequest("friend");
    GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);
    System.out.println(response.getAliases());
    System.out.println(response.getMappings());
    System.out.println(response.getSettings());

//    关闭es客户端
    client.close();
  }
}
